package io.github.talelin.latticy.model.oms;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.github.talelin.latticy.common.enumeration.InboundOrderEnum;
import io.github.talelin.latticy.common.enumeration.InboundOrderStatusEnum;
import com.baomidou.mybatisplus.annotation.TableName;

import java.time.LocalDateTime;
import java.util.Date;
import io.github.talelin.latticy.dto.oms.inbound_order.InboundOrderCreateDTO;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

/**
 * 入库单表
 *
 * @author generator@mrxiao
 * @since 2022-05-16
 */
@Data
@Accessors(chain = true)
@TableName(value = "t_inbound_order", excludeProperty = {"inboundPackagesList", "senderAddress"})
@NoArgsConstructor
public class InboundOrderDO {

    /**
     * 入库单编号系统生成
     */
    @TableId(value = "inbound_order_no", type = IdType.INPUT)
    private String inboundOrderNo;

    /**
     * 租户(客户代码)
     */
    private String tenant;

    /**
     * 入库类型​(1.常规入库 2.入库和转运)
     */
    private InboundOrderEnum inboundOrderType;

    /**
     * 货柜类型 1.箱子 2.托盘栈板 3.代表20 4.代表20GP 5.代表40GP 6.代表40HQ 7.代表45GP 8.代表45HQ
     */
    private Integer containerType;

    /**
     * 0取消(删除),1草稿,2已审核,3.在途,4仓库收货,5收货完成,6上架完成
     */
    private InboundOrderStatusEnum inboundOrderStatus;

    /**
     * 运输方式
     */
    private String shippingMethod;

    /**
     * 预计送达时间
     */
    private String estimateDeliveryTime;

    /**
     * 入库栈板
     */
    private Integer inboundPallet;

    /**
     *   接受栈板数据
     */
    private Integer receivingInboundPallet;

    /**
     * 采购订单号(用英文,号分割)
     */
    private String purchaseOrderNo;

    /**
     * 物流跟踪号(用英文,号分割)
     */
    private String trackingNumber;

    /**
     * 仓库code
     */
    private String warehouseCode;

    /**
     * 头程收货单号, 用于页面显示
     */
    private String transitReceivingCode;

    /**
     * 揽收时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime incomeTime;

    /**
     * 揽收状态：0未揽收，1揽收中，2已揽收，3已入库
     */
    private Integer incomeStatus;



    /**
     * 中转状态 0:草稿;1:待处理;2:处理中;3:处理完成
     */
    private Integer orderTransferStatus;

    /**
     * 已收货件数
     */
    private Integer receivingCount;

    /**
     * 接受箱数
     */
    private Integer receivingPackageCount;


    /**
     * 总件数
     */
    private Integer totalNumber;


    /**
     * sku种类数
     */
    private Integer skuTotal;

    /**
     * 总箱数
     */
    private Integer totalPackages;

    /**
     * 入库单完成时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime completionTime;

//    private List<InboundPackagesDO> inboundPackagesList;
//
//
//    private List<InboundItemCountDTO> inboundItemCount;



    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @TableLogic
    private Date deleteTime;

//    /**
//     * 寄件人地址相关信息
//     */
//    private SenderAddressDO senderAddress;


    public InboundOrderDO(InboundOrderCreateDTO validator, String billNo, String tenant) {
        BeanUtils.copyProperties(validator, this);
        this.inboundOrderNo = billNo;
        this.tenant = tenant;
    }


}
